// pages/dogDetail/dogDetail.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    statusList:['在读','请假','休学','毕业','汪星'],
  },

  showIt(e){
    console.log(e)
    const all = e.currentTarget.dataset.all
const url = e.currentTarget.dataset.url
wx.previewImage({
  current:url,
  urls: all.map(i=>i.photoUrl),
})
  },
  async followIt(){
    
const res = await getApp().$request('/api/addFollow','POST',{dogId:this.data.dogId,userId:wx.getStorageSync('user').id})
wx.showToast({
  title: '关注成功',
})
this.getInfo()
},

  async delfollowIt(){
    const res = await getApp().$request('/api/delFollow','POST',{dogId:this.data.dogId,userId:wx.getStorageSync('user').id})
    wx.showToast({
      title: '取关成功',
    })
    this.getInfo()
  },

  navToLy(){
    wx.navigateTo({
    
    url: '/pages/want/want',
    })
  },
navToPj(e){
  
  wx.navigateTo({
  
  url: '/pages/reviewDetail/reviewDetail?dogId='+this.data.dogId,
  })
},
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
this.data.dogId = options.dogId
this.getInfo()

  },
async likeDog(){
const res =  await getApp().$request('/api/likeDog','POST',{dogId:this.data.dogId,userId:wx.getStorageSync('user').id})
this.getInfo()
},
  
  async getInfo(){
const res = await getApp().$request('/api/getDogById','POST',{dogId:this.data.dogId,userId:wx.getStorageSync('user').id})
this.setData({
  dog:res.data
})
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },

  scrollToReviews() {
    wx.createSelectorQuery()
        .select('#reviews')
        .boundingClientRect(function(rect){
            // 获取评价区域的位置
            wx.pageScrollTo({
                scrollTop: rect.top,
                duration: 300  // 滚动动画时长，单位为ms
            })
        })
        .exec()
  },

  // 可选：添加其他区域的跳转方法
  scrollToDetail() {
    wx.pageScrollTo({
        scrollTop: 0,
        duration: 300
    })
  },

  scrollToAlbum() {
    wx.createSelectorQuery()
        .select('#album')
        .boundingClientRect(function(rect){
            wx.pageScrollTo({
                scrollTop: rect.top,
                duration: 300
            })
        })
        .exec()
  }
})